Learn how to mint collectibles using a gasless serverless Transactions API with Sequence. Implement the API on a Cloudflare worker for seamless user interactions without gas payments.
mkdir
, cd
into the project, and run pnpm init
to create a package.json
.
Next, make sure wrangler cli is installed in your project and set the wrangler
keyword as an alias in your local bash session.
"Hello World" Worker
application.
wrangler init
with the last 2 step answered as No
to decline git versioning and deployment.
This will clone down a starter repository that can be used to deploy code to the cloud.
wrangler dev
command in the project folder for local testingcd
into the randomly generated project folder, and perform a wrangler deploy
command.
This should print a URL, which you can enter in the browser the URL https://<app>.<account>.workers.dev
to view the Hello World!
result.
Developer
for your project in Sequence Builder which can be with this walkthroughminter permission
to your Sequence Wallet Transactions API Address
.
In order to know what the transactions API address you are working with is, one must first either:
generate local wallet
button (for demo purposes only)Recommended
: You can also print locally the account address produced from an EOA wallet private key using the following code snippet:Contracts
page, select your Linked contracts
and under Write Contract
tab expand the grantRole
method.
Complete with the following details:
bytes32 role
: 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6
address account
: <Generated Sequence Transactions API Wallet Address>
role
string inputted is the result of keccak256("MINTER_ROLE")
in solidity or ethers.keccak256(ethers.toUtf8Bytes("MINTER_ROLE"))
in javascript
This makes it so that only your specific address can mint from the contract, it will error otherwise.
Complete the role update by clicking write
and sign the sponsored transaction.
ethers
and 0xsequence
to get access to sequence APIs in order to perform a proof validation that the request is coming from a trusted source, a sequence wallet.
proofString
and address
are valid, as well as the environment variables.
The code scaffold placed into src/index.ts
would look like this, with callContract
and getBlockNumber
mocked out, using the mentioned verification step of calling verify
before any contract call.
[vars]
section in your wrangler.toml
.
window
object required by the web3 modules.
To prevent this, add the following line to your wrangler.toml
file to make the environment compatible.
wrangler deploy
And perform a curl request to test your endpoint like such:
connect
button and then copy to clipboard
.
ETHAuthProof
with anyone as this means someone can prove ownership of your wallet and interact with specific APIs.
Finally, replace the url
with your app from this step, the <some_proof>
with the generated value copied from the viewer dapp, and <some_address>
with your wallet address and it should return just the mocked 0x
string.
callContract
and getBlockNumber
methods previously mocked out as follows: